<template>
  <div>
    <div class="content">
      <div class="list" :class="{'active': item.active}" v-for="(item, index) in list" :key="item.id" @click="goChapter(item.courseId)" @mouseover="mouseOver(index)" @mouseleave="mouseLeave" >
        <div :class="{'active': item.active}">
          {{item.courseName}}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { courseList } from "@/api/system/user";
export default {
  components: {
   
  },
  data() {
    return {
      list: [
      ],
      active: '',
    }
  },
  created() {
    
  },
  mounted(){
    this.getList()
  },
  methods: {
    mouseOver(index) {
      this.list.forEach(element => {
        element.active = false
      });
      this.list[index].active = true
    },
    mouseLeave: function () {
        this.active = false
    },
    goChapter(courseId) {
      this.$router.push({ path: "/queList", query: { courseId: courseId}})
    },
    //课程列表
    getList() {
      courseList().then(res => {
        if (res.code == '200') {
          this.list = res.rows
          this.list.forEach(element => {
            element.active = false
          });
          this.list = JSON.parse(JSON.stringify(this.list))
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    
  }
}
</script>
<style scoped>
  .form {
    padding-left: 26px;
    padding-right: 24px;
    padding-top: 24px;
    background: #fff;
  }
  .search {
    display: flex;
    position: relative;
  }
  .search_info {
    width: 192px;
    height: 40px;
    margin-right: 16px;
  }
  .searchBtn {
    margin-left: 16px;
    height: 36px;
  }
  .sortStyle {
    height: 19px;
    float: right;
    /* right: 24px; */
    margin-top: 20px;
    margin-bottom: 30px;
  }
  .pos_right_btn {
    position: absolute;
    right: 0;
  }
  .opt_font {
    cursor: pointer;
    color: #2e82ff;
  }
 .detail_title {
    font-size: 16px;
    font-weight: 400;
    color: #212121;
    line-height: 22px;
  }
  .detail_title span {
    padding-left: 4px;
    background: #1e88e5;
    margin-right: 12px;
  }
  .row {
    display: flex;
    padding-bottom: 12px;
  }
  .detail_info {
    padding-top: 16px;
  }
  .info_left {
    display:flex;
  }
  .info_right {
    display: flex;
    padding-left: 202px;
  }
  .info_left_title {
    font-size: 14px;
    font-weight: 400;
    color: #616161;
    line-height: 20px;
    width: 112px;
    margin-right: 16px;
  }
  .info_left_content {
    font-size: 14px;
    font-weight: 400;
    color: #212121;
    line-height: 20px;
    width: 150px;
  }
  .pos_top {
    padding-top: 12px;
  }
  .detailTable {
    margin-top: 16px;
  }
  .opt_font {
    color: #1e88e5;
    cursor: pointer;
  }
  .page_pos {
    text-align: right;
    padding-top: 10px;
  }
  .backBtn {
    text-align: center;
    margin-top:10px;
  }
  /deep/ .el-dialog {
    display: flex;
    flex-direction: column;
    margin:0 !important;
    position: absolute;
    top:50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: calc(100% -30px);
    /* max-width: ; */
  }
  /deep/ .el-dialog .el-dialog__body {
    flex: 1;
    height: 700px;
    overflow-y: auto;
    padding-top: 0;
  }
  .tab {
    display: flex;
    position: absolute;
    right: 32px;
    top:14px;
  }
  .tab_border {
    border: 1px solid #409EFF;
    color: #409EFF;
    padding:10px 12px;
    font-size: 14px;
    margin-right: 16px;
  }
  .change {
    border: 1px solid #F56C6C;
    color: #F56C6C;
  }
  .listTable {
    margin-top: 17px;
  }
  .footer {
    display: flex;
    justify-content: center;
    margin-top: 20px;
  }
  .opt_table {
    display: flex;
    justify-content: space-around;
  }
  .content {
    padding-left: 26px;
    padding-top: 26px;
  }
  .list {
    margin-bottom: 20px;
    cursor: pointer;
  }
  .active {
    color: #2e82ff
  }
</style>
